package rescsa.gob.pe.seguridad.dao;

import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;
import org.springframework.stereotype.Repository;

import rescsa.gob.pe.constants.RowMapperConstants;
import rescsa.gob.pe.personal.bean.DistritoBEAN;

@Repository
public class DistritoDAO {
	
	private SimpleJdbcTemplate simpleJdbcTemplate;
    private JdbcTemplate jdbcTemplate;
	private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
	
	@Autowired
	public void init(DataSource dataSource) {
		this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);
		this.jdbcTemplate=new JdbcTemplate(dataSource);
		this.namedParameterJdbcTemplate=new NamedParameterJdbcTemplate(dataSource);
	}
	
	
	
//	OBTENER POR ID
	@SuppressWarnings("unchecked")
	public DistritoBEAN obtenerXID(DistritoBEAN distritoDTO){		
		String sql= "select * from distrito where  1 = 1 and c_distrito = :c_distrito";
		Map<String, Object> parametros= new HashMap<String, Object>();
		parametros.put("c_distrito",distritoDTO.getC_distrito());
		return  this.simpleJdbcTemplate.queryForObject(sql,new RowMapperConstants.DistritoMapper(), parametros);		
	}

}
